﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Joyintech.Model.inpiao365;
using Joyintech.BLL.inpiao365;

namespace Joyintech.Web.inpiao365.PhenixTicket
{
    public partial class phenix_seat_list_new : System.Web.UI.Page
    {
        #region 页面变量赋值

        protected String lsh;//电影编号
        protected String yth;//影厅编号
        protected String yyh;//影院编号
        protected String cc;//场次编号
        protected string movieimg;//电影logo
        protected string moviename;//电影名称
        protected string movietype;//电影类型
        protected string moviedcc;//电影场次
        protected string theatername;//影院名称
        protected string movietime;//片长
        protected string movieprice;//票价
        protected string theaterRoom;//放映厅
        protected string theaterRoomSeat;//放映厅座位数

        #endregion


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                lsh = Request["lsh"];
                yth = Request["yth"];
                cc = Request["cc"];
                yyh = Request["yyh"];
                //获取当前登录用户
                customer currentCustomer = customer_BLL.GetInstance().GetCurrentCustomer();

                if (currentCustomer != null)
                {
                    this.txt_Mobile.Text = currentCustomer.CustomerPhone;

                }
                Bind();
                BindView();
            }
        }

        /// <summary>
        /// 计取影厅座位的静态html地址
        /// </summary>
        private void Bind()
        {
            theaterRoom_BLL bll = new theaterRoom_BLL();
            theaterRoom model = bll.GetModel(int.Parse(yth));
            TheaterRoomMapUrl.Value = model.TheaterRoomMapUrl;
        }

        /// <summary>
        /// 绑定页面变量
        /// </summary>
        private void BindView()
        {
            movie_BLL movieBll = new movie_BLL();
            movie moviemodel = movieBll.GetModelByCache(int.Parse(lsh));
            movieimg = moviemodel.MovieLogo;
            moviename = moviemodel.MovieName;
            movietype = moviemodel.MovieType;
            movietime = moviemodel.Trailer.Value.ToString();

            theaterRoom_BLL theaterroombll = new theaterRoom_BLL();
            theaterRoom theaterroom = theaterroombll.GetModelByCache(int.Parse(yth));
            theaterRoom = theaterroom.TheaterRoomName;
            theaterRoomSeat = theaterroom.TheaterRoomSeat.ToString();

            screenings_BLL screeningsbll = new screenings_BLL();
            screenings screenings = screeningsbll.GetModelByCache(int.Parse(cc));
            movieprice = screenings.Price.ToString();
            moviedcc = screenings.MovieSeatTime.ToString() + "(" + TransformDay((int)screenings.MovieSeatTime.DayOfWeek) +")";

            theater_BLL theaterbll = new theater_BLL();
            Joyintech.Model.inpiao365.theater theater = theaterbll.GetModelByCache(int.Parse(yyh));
            theatername = theater.TheaterName;

        }

        /// <summary>
        /// 转换成中文星期
        /// </summary>
        /// <param name="week"></param>
        /// <returns></returns>
        private string TransformDay(int week)
        {
            string xingqi = string.Empty;
            if (week == 0)
            {
                xingqi = "星期日";
            }
            else if (week == 1)
            {
                xingqi = "星期一";
            }
            else if (week == 2)
            {
                xingqi = "星期二";
            }
            else if (week == 3)
            {
                xingqi = "星期三";
            }
            else if (week == 4)
            {
                xingqi = "星期四";
            }
            else if (week == 5)
            {
                xingqi = "星期五";
            }
            else
            {
                xingqi = "星期六";
            }

            return xingqi;
        }
    }
}